package com.hmdp.config;

public class test {
    public static int removeDuplicates(int[] nums) {
        if (nums.length <= 2) {
            return nums.length;
        }

        int index = 2; // 从第三个元素开始处理

        for (int i = 2; i < nums.length; i++) {
            // 如果当前元素与index-2位置的元素不同，则可以保留
            if (nums[i] != nums[index - 2]) {
                nums[index] = nums[i];
                index++;
            }
        }
        //输出返回数组
        for (int i = 0; i < index; i++) {
            System.out.print(nums[i]);
        }

        return index;
    }

    public static void main(String[] args) {
        int nums[] = new int[]{0,0,0,1,1,1,1,2,3,3};
        removeDuplicates(nums);

    }
}
